﻿using System;
using System.Collections;
using System.Data;
using CE.Database;

/// <summary>
/// Summary description for WegoHotelsDB
/// </summary>
/// 
namespace CE.Wego
{
    public class WegoHotelsDB
    {
        public WegoHotelsDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(WegoHotelsInfo wegohotels)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocWegoHotelsInsertSingleItem";

            SortedList _sPara = new SortedList();
            #region Parameter

            _sPara.Add("@ViewId", wegohotels.ViewId);
            _sPara.Add("@Currency", wegohotels.Currency);
            _sPara.Add("@SortBy", wegohotels.SortBy);
            _sPara.Add("@OrderBy", wegohotels.OrderBy);
            _sPara.Add("@RecCount", wegohotels.RecCount);
            _sPara.Add("@FilteredCount", wegohotels.FilteredCount);
            _sPara.Add("@TotalCount", wegohotels.TotalCount);
            _sPara.Add("@ID", wegohotels.ID);
            _sPara.Add("@HotelName", wegohotels.HotelName);
            _sPara.Add("@Description", wegohotels.Description);
            _sPara.Add("@Stars", wegohotels.Stars);
            _sPara.Add("@Address", wegohotels.Address);
            _sPara.Add("@Image", wegohotels.Image);
            _sPara.Add("@Satisfaction", wegohotels.Satisfaction);
            _sPara.Add("@Rank", wegohotels.Rank);
            _sPara.Add("@Latitude", wegohotels.Latitude);
            _sPara.Add("@Longitude", wegohotels.Longitude);
            _sPara.Add("@Type", wegohotels.Type);
            _sPara.Add("@Num_Reviews", wegohotels.Num_Reviews);
            _sPara.Add("@Num_Positive_Reviews", wegohotels.Num_Positive_Reviews);
            _sPara.Add("@Num_Negative_Reviews", wegohotels.Num_Negative_Reviews);
            _sPara.Add("@Num_Neutral_Reviews", wegohotels.Num_Neutral_Reviews);


            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 InsertSearch(string Location, DateTime CheckinDate, DateTime CheckoutDate)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocWegoHotelsSearchInsertSingleItem";

            SortedList _sPara = new SortedList();
            #region Parameter

            _sPara.Add("@Location", Location);
            _sPara.Add("@CheckinDate", CheckinDate);
            _sPara.Add("@CheckoutDate ", CheckoutDate);

            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 UpdateSearch(Int64 ViewId)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocWegoHotelsSearchUpdateSingleItem";

            SortedList _sPara = new SortedList();
            #region Parameter

            _sPara.Add("@HotelSearchId", ViewId);

            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataTable GetWegoHotelsList(Int64 ViewID)
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable("HotelList");
            string _spName = "sprocWegoHotelsSelectItemList";
            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@ViewId", ViewID);
            #endregion

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);
            return _dtResult;
        }
    }
}
